import { AppRouteRecordRaw } from './type'
import { ErrorPage403, ErrorPage404, ErrorPage500, RedirectHome, RedirectUnPublish } from './constant'
import { PageEnum } from './../enums/pageEnum'
import { RouteRecordRaw } from 'vue-router'
import { GoReload } from '@/components/GoReload'

// 登录
export const LoginRoute: RouteRecordRaw = {
  path: PageEnum.BASE_LOGIN,
  name: PageEnum.BASE_LOGIN_NAME,
  component: () => import('@/views/login/index.vue'),
  meta: {
    title: '登录'
  }
}

// 错误页面
export const HttpErrorPage: RouteRecordRaw[] = [
  {
    path: '/error/404',
    name: PageEnum.ERROR_PAGE_NAME_404,
    component: ErrorPage404,
    meta: {
      title: PageEnum.ERROR_PAGE_NAME_404
    }
  },
  {
    path: '/error/403',
    name: PageEnum.ERROR_PAGE_NAME_403,
    component: ErrorPage403,
    meta: {
      title: PageEnum.ERROR_PAGE_NAME_403
    }
  },
  {
    path: '/error/500',
    name: PageEnum.ERROR_PAGE_NAME_500,
    component: ErrorPage500,
    meta: {
      title: PageEnum.ERROR_PAGE_NAME_500
    }
  }
]

// 通配符*路由
export const ErrorPageRoute: AppRouteRecordRaw = {
  path: '/:path(.*)*',
  name: 'ErrorPage',
  component: ErrorPage404,
  meta: {
    title: PageEnum.ERROR_PAGE_NAME_404,
    hideBreadcrumb: true
  }
}

// 重载
export const ReloadRoute: AppRouteRecordRaw = {
  path: PageEnum.RELOAD,
  name: PageEnum.RELOAD_NAME,
  component: GoReload,
  meta: {
    title: PageEnum.RELOAD_NAME
  }
}

// 重定向
export const RedirectRoute: RouteRecordRaw[] = [
  {
    path: PageEnum.REDIRECT,
    name: PageEnum.REDITECT_NAME,
    component: RedirectHome,
    meta: {
      title: PageEnum.REDITECT_NAME
    }
  },
  {
    path: PageEnum.REDIRECT_UN_PUBLISH,
    name: PageEnum.REDIRECT_UN_PUBLISH_NAME,
    component: RedirectUnPublish,
    meta: {
      title: PageEnum.REDIRECT_UN_PUBLISH_NAME
    }
  }
]
